﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SharingCenter.Web.Shared
{
    public partial class ValicationCode : System.Web.UI.UserControl
    {
        public string ValidationGroup { get; set; }

        public short TabIndex
        {
            get;
            set;
        }
        public bool IsValid 
        {
            get
            {
                return txtVCode.Text.Trim().ToLower() == Session["SK_VC"].ToString().ToLower();
            }
        }

        protected void Page_Init(object sender, EventArgs e)
        {
            CustomValidator1.ServerValidate += new ServerValidateEventHandler(CustomValidator1_ServerValidate);
        }

        void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
        {
            args.IsValid = args.Value.Trim().ToLower() == Session["SK_VC"].ToString().ToLower();
        }

        public void Page_PreRender(object sender, EventArgs e)
        {
            txtVCode.TabIndex = TabIndex;
            CustomValidator1.ValidationGroup = ValidationGroup;
        }
    }
}